// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'



import AlertPlugin from 'vux/src/plugins/alert'
import LoadingPlugin from 'vux/src/plugins/loading'
import ToastPlugin from 'vux/src/plugins/toast'
import infiniteScroll from 'vue-infinite-scroll'

import App from './App'

// import Home from './pages/Home'

import Player from './components/Player.vue'
import CustomerFooter from './components/Footer.vue'
import NotFound from './pages/NotFound.vue'
import Empty from './components/Empty.vue'
import followBtn from './components/FollowBtn'


const Home = resolve => require(['./pages/Home'], resolve)
const Question = resolve => require(['./pages/QuestionDetail'], resolve)
const Professor = resolve => require(['./pages/Professor'], resolve)
const Professors = resolve => require(['./pages/Professors'], resolve)
const Me = resolve => require(['./pages/Me'], resolve)
const BecomeProfessor = resolve => require(['./pages/BecomeProfessor'], resolve)
const AskedPage = resolve => require(['./pages/AskedPage'], resolve)
const ListenedPage = resolve => require(['./pages/ListenedPage'], resolve)
const AnsweredPage = resolve => require(['./pages/AnsweredPage'], resolve)
const Feedback = resolve => require(['./pages/Feedback'], resolve)
const FollowPage = resolve => require(['./pages/FollowPage'], resolve)
const About = resolve => require(['./pages/About'], resolve)


//jssdk instance
let wx = require('weixin-js-sdk');
let bus = new Vue();
Vue.prototype.bus = bus;
Vue.prototype.wx = wx;
let debug = false;
if (!debug) {
    Vue.prototype.url = {
        acid: 'http://fx-v2.5ifenxiao.cn/app/index.php?i=8&m=fdfengshui&c=entry',
        root: 'http://fx-v2.5ifenxiao.cn'
    }
} else {
    Vue.prototype.url = {
        acid: 'http://1535uf1143.iask.in/app/index.php?i=3&m=fdfengshui&c=entry',
        root: 'http://1535uf1143.iask.in'
    }
}


Vue.component('player', Player)
Vue.component('follow-btn', followBtn)
Vue.component('empty', Empty)
Vue.use(infiniteScroll)
Vue.component('customer-footer', CustomerFooter)

Vue.use(VueRouter)
Vue.use(VueResource)
Vue.use(LoadingPlugin)
Vue.use(AlertPlugin)
Vue.use(ToastPlugin)

const routes = [{
        path: '/',
        name: 'home',
        component: Home
    },
    {
        path: '/question/:id',
        name: 'question',
        component: Question
    },
    {
        path: '/professor/:id',
        name: 'professor',
        component: Professor
    },
    {
        path: '/professors',
        name: 'professors',
        component: Professors
    },
    {
        path: '/me',
        name: 'me',
        component: Me
    },
    {
        path: '/me/becomeprofessor',
        name: 'becomeprofessor',
        component: BecomeProfessor
    },
    {
        path: '/me/ask',
        component: AskedPage
    },
    {
        path: '/me/listen',
        component: ListenedPage
    },
    {
        path: '/me/answer',
        component: AnsweredPage
    },
    {
        path: '/feedback',
        component: Feedback
    },
    {
        path: '/about',
        component: About
    },
    {
        path: '/me/follow',
        component: FollowPage
    },
    {
        path: '/me/*',
        component: NotFound
    }
]

// const router = new VueRouter({
//     mode: 'history',
//     routes: routes
// })
const router = new VueRouter({
    routes
})

FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
    router,
    render: h => h(App)
}).$mount('#app-box')